package com.bitter;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.slf4j.MDC;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.context.properties.EnableConfigurationProperties;

@SpringBootApplication
@EnableConfigurationProperties
public class SpringApplicationRunner {
    // 会话ID
    private final static String FILE_KEY_ID = "file-key-Id";

    private static final Logger log = LoggerFactory.getLogger(SpringApplicationRunner.class);

    public static void main(String[] args) throws Exception {
        //sl4j 提供的一个工具类MDC
        MDC.put(FILE_KEY_ID, java.util.UUID.randomUUID().toString().replaceAll("-", "").toUpperCase() + "-log");
        log.info("info 日志");

        log.info("测试日志是否可以输了，输入的日志数据为: `{}`", "SiftingAppender-log");
        // 最后执行MDC删除
        MDC.clear();
        SpringApplication.run(SpringApplicationRunner.class, args);
    }

}
